//
//  QZHomeBaoSignCell.m
//  CollectionVIewDemo
//
//  Created by 栗子 on 2017/12/13.
//  Copyright © 2017年 http://www.cnblogs.com/Lrx-lizi/. All rights reserved.
//

#import "QZHomeBaoSignCell.h"
@interface QZHomeBaoSignCell ()

/*任务图片*/
@property (nonatomic, strong) UIImageView *iconIV;
/*任务奖励数量*/
@property (nonatomic, strong) UILabel *nameLB;
/*任务天数*/
@property (nonatomic, strong) UILabel *dayLB;
//下线线
@property (nonatomic, strong) UIView *downLine;
//右线
@property (nonatomic, strong) UIView *rightLine1;
//右线
@property (nonatomic, strong) UIView *rightLine2;

@end


@implementation QZHomeBaoSignCell

- (void)showOldAddNavViewToMainOldView1{
    UIView * oldBgSS = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    oldBgSS.clipsToBounds = YES;
    [self addSubview:oldBgSS];
    
    UIButton * sendBtn = [[UIButton alloc]initWithFrame:CGRectMake(KScreen_W-75, kStatusBarHeight+10, 60, 46)];
    sendBtn.layer.cornerRadius = 3;
    sendBtn.backgroundColor = [UIColor whiteColor];
    [sendBtn setTitle:@"发送" forState:UIControlStateNormal];
    [sendBtn setTitleColor:ColorHex(@"#333333") forState:UIControlStateNormal];
    sendBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [sendBtn addTarget:self action:@selector(sendTap) forControlEvents:UIControlEventTouchUpInside];
    [oldBgSS addSubview:sendBtn];
    
    UIView * sendBg = [[UIView alloc]initWithFrame:CGRectMake(15, kStatusBarHeight+66, KScreen_W-30, (KScreen_H-KSafeAreaBottomHeight-25-(kStatusBarHeight+66))/2)];
    sendBg.backgroundColor = [UIColor whiteColor];
    sendBg.layer.cornerRadius = 3;
    [oldBgSS addSubview:sendBg];
    
    UILabel * sendTip = [[UILabel alloc]initWithFrame:CGRectMake(0, (sendBg.frame.size.height-40)/2, sendBg.frame.size.width, 40)];
    sendTip.text = @"发送区";
    sendTip.textColor = ColorHex(@"#f0f0f0");
    sendTip.textAlignment = NSTextAlignmentCenter;
    sendTip.font = [UIFont systemFontOfSize:28];
    [sendBg addSubview:sendTip];
}
- (void)awakeFromNib {
    [super awakeFromNib];
}

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self addSubviews];
    }
    return self;
}
-(void)addSubviews{
    
    self.iconIV = [[UIImageView alloc]init];
    [self.contentView addSubview:self.iconIV];
    [self.iconIV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_offset(0);
        make.centerX.equalTo(self.mas_centerX).offset(0);
        make.size.mas_offset(20);
    }];
    
    
    self.nameLB = [[UILabel alloc]init];
    [self.contentView addSubview:self.nameLB];
    [self.nameLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.iconIV.mas_bottom).offset(4);
        make.centerX.equalTo(self.mas_centerX).offset(0);
        make.width.mas_offset(60);
        make.height.mas_offset(12);
    }];
    self.nameLB.text = @"+0";
    self.nameLB.font = FontMedium(9);
    self.nameLB.textColor = ThreeColor;
    self.nameLB.backgroundColor = UIColor.whiteColor;
    self.nameLB.textAlignment = NSTextAlignmentCenter;

    
    self.dayLB = [[UILabel alloc]init];
    [self.contentView addSubview:self.dayLB];
    [self.dayLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nameLB.mas_bottom).offset(17);
        make.centerX.equalTo(self.mas_centerX).offset(0);
        make.width.mas_offset(60);
        make.height.mas_offset(12);
    }];
    self.dayLB.text = @"+0";
    self.dayLB.font = FontMedium(9);
    self.dayLB.textColor = ThreeColor;
    self.dayLB.backgroundColor = UIColor.whiteColor;
    self.dayLB.textAlignment = NSTextAlignmentCenter;
   
    self.downLine = [[UIView alloc]init];
    [self.contentView addSubview:self.downLine];
    [self.downLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nameLB.mas_bottom).offset(7.5);
        make.height.mas_offset(2);
        make.width.mas_offset(65);
    }];
    self.downLine.backgroundColor = COLOR_ALPH(245,144,188,0.5);
    
    
    self.rightLine1 = [[UIView alloc]init];
    [self.contentView addSubview:self.rightLine1];
    [self.rightLine1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nameLB.mas_bottom).offset(7.5);
        make.width.mas_offset(2);
        make.height.mas_offset(41.5);
        make.right.mas_offset(0);
    }];
    self.rightLine1.backgroundColor = COLOR_ALPH(245,144,188,0.5);
    
    self.rightLine2 = [[UIView alloc]init];
    [self.contentView addSubview:self.rightLine2];
    [self.rightLine2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_offset(0);
        make.width.mas_offset(2);
        make.height.mas_offset(43.5);
        make.right.mas_offset(0);
    }];
    self.rightLine2.backgroundColor = COLOR_ALPH(245,144,188,0.5);
    
    self.downLine.hidden = NO;
    self.rightLine1.hidden = YES;
    self.rightLine2.hidden  = YES;
}
-(void)cellIndexPathRow:(NSInteger)row nextRow:(NSInteger)nextRow Confin:(NSDictionary *)dic{
//    if(row == 4){
//        self.rightLine1.hidden = YES;
//        self.rightLine2.hidden  = YES;
//        self.downLine.hidden = YES;
//        self.iconIV.hidden = YES;
//        self.nameLB.hidden = YES;
//        self.dayLB.hidden = YES;
//        return;
//    }
    self.downLine.hidden = NO;
    self.iconIV.hidden = NO;
    self.nameLB.hidden = NO;
    self.dayLB.hidden = NO;
    if(row == 3){
        self.rightLine1.hidden = NO;
        self.rightLine2.hidden  = YES;
    }else if (row == 7){
        self.rightLine1.hidden = YES;
        self.rightLine2.hidden  = NO;
    }else{
        self.rightLine1.hidden = YES;
        self.rightLine2.hidden  = YES;
    }
    self.iconIV.image = KImageNamed(@"ico_home_jinbi");
    self.nameLB.text = [NSString stringWithFormat:@"+%@",dic[@"integration"]];
    if([dic[@"is_today"] intValue] == 1 && [dic[@"sign_in"] intValue] == 0){
        self.dayLB.text = @"签到可领";
        self.nameLB.textColor = MainColor;
        self.dayLB.textColor = MainColor;
    }else if(row == nextRow){
        self.dayLB.text = @"明日可领";
        self.nameLB.textColor = MainColor;
        self.dayLB.textColor = MainColor;
    }else if([dic[@"sign_in"] intValue] == 1){
        self.dayLB.text = @"已签到";
        self.nameLB.textColor = MainColor;
        self.dayLB.textColor = MainColor;
    }else{
        self.dayLB.text = [NSString stringWithFormat:@"%@",dic[@"week_text"]];
        self.nameLB.textColor = ThreeColor;
        self.dayLB.textColor = ThreeColor;
    }
}

@end
